package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.xmlgen.AddPropertyNameAsAttribute;
import net.peelmeagrape.hibernate.xmlgen.ChildElement;
import net.peelmeagrape.hibernate.Column;
import net.peelmeagrape.hibernate.Meta;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;

/**
 * Annotate a property of a {@link CompositeMapKey}.
 */
@Target({METHOD,FIELD}) @Retention(RUNTIME)
@XmlElement(name="key-property")
@AddPropertyNameAsAttribute(name="name")
public @interface KeyProperty
{
    @ChildElement(0) Meta[] meta() default {};
    /**
     * The strategy Hibernate should use for accessing the property value. This may be one of
     * 'property', 'field', 'embedded', or the name of a subclass of {@link org.hibernate.property.PropertyAccessor}.
     */
    @XmlAttribute String access() default "property";
    @XmlAttribute String type() default "";
    @XmlAttribute String column() default "";
    @XmlAttribute int length() default 255;
    @ChildElement(1) Column[] columnMapping() default {};
    @XmlAttribute String node() default "";
}
